import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { ICustomerFull } from "@/types/pages/customer/interface";
import { getIncomeLineChart,
    getPieIProfitChart,
    getPieIProfitTypeChart,
    getPieIncomeChart,
    getPieIncomeTypeChart,
    getProfitLineChart,
    getTotalIncomeData,
    getTotalProfitData
} from "@/api/finance";
import { IFinanceFull } from "@/types/pages/finance/interface";
import { IStore } from "@/types/pages/base";

/**
 * class Finance
 * 财务分析
 */
class Finance implements IStore<IFinanceFull> {
    @observable screenData :IFinanceFull= {
        profit: {}, incomePie: {}, incomeTypePie: {},
        profitPie: {}, profitTypePie: {}, incomeLine: {}, profitLine: {},
        income: {}
    }

    constructor() {
      makeObservable(this)
  }
   /**
     *
     * @param type 日期选择函数
     * @param date 传入日期
     */
     @action async getScreenData(type: PageDateSelect,date?:Date) {
        // 获取左上部分
        this.screenData.incomeLine= await getIncomeLineChart(type,date);
        this.screenData.profitPie= await getPieIProfitChart(type,date);
        this.screenData.profitTypePie= await getPieIProfitTypeChart(type,date);
        this.screenData.incomePie= await getPieIncomeChart(type,date);
        this.screenData.incomeTypePie= await getPieIncomeTypeChart(type,date);
        this.screenData.profitLine= await getProfitLineChart(type,date);
        this.screenData.income=await  getTotalIncomeData(type,date);
        this.screenData.profit=await  getTotalProfitData(type,date);
        return  this.screenData;
    }


}
export default Finance;
